/************ 项目页面 ********** */

import {getProBriefTree,getResourceTree,getPushProList,getProDetail,getComments} from '@/services/modules/pro';
import {getStudentTable} from '@/services/modules/student/studentPro';
import {RootObject4,RootObject5,RootObject6,StudentTableList,StudentTable,commontList} from '@/utils/proXm';
import {makeAutoObservable} from 'mobx';
import {DetailObject} from '@/utils/proXm';

interface commonts{
    id: string;
    pageNum: number;
    pageSize: number;
}
class ProXm {
    constructor(){
        makeAutoObservable(this);
    }
    proBriefTree:RootObject4[] = [];    // 实训大纲
    proResourceTree:RootObject5[] = []; // 项目资源
    proPushProList:RootObject6[] = [];  // 前置项目
    // proDetails = {name:'',version:'',description:'',stationName:'',tradeName:'',sxType:0,subjectTime:0};    // 详情
    proDetails = {} as DetailObject;
    studentTables:StudentTableList[] = [];  //学生项目表格
    commontList:commontList[] = [];

    // 实训大纲
    async getProBriefTree(){
        let res = await getProBriefTree();
        if(res.code === 200){
            this.proBriefTree = res.data;
            console.log(res.data)
        }
    }
    // 项目资源
    async getResourceTree(){
        let res = await getResourceTree();
        if(res.code === 200){
            this.proResourceTree = res.data;
        }
    }
    // 前置项目
    async getPushProList(){
        let res = await getPushProList();
        if(res.code === 200){
            this.proPushProList = res.data;
        }
    }
    // 获取详情
    async getProDetail(id:string | string[]){
        let res = await getProDetail(id);
        
        if(res.code === 200){
            let abc = {...res.data};
            this.proDetails = abc
        }
    }
    // 清空回显
    clearDetail(){
        this.proDetails  = {} as DetailObject
    }
    /************学生端项目************ */
    // 获取学生端tableList
    async getStudentTable(params:StudentTable){
        let res = await getStudentTable(params);
        // console.log('学生端',res)
        this.studentTables = res.rows;
    }
    // 获取学生端评论
    async getComments(params:commonts){
        let res = await getComments(params);
        this.commontList = res.rows;
        console.log('评论',res)
    }
}

// 抛出
export default new ProXm;